Skip to content

Conversation

romtsn
Copy link
Member

@romtsn romtsn commented Oct 9, 2025

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

  • This moves the entire script logic from afterEvaluate (which is too late to register tasks) into androidComponents.onVariants. Since our tasks only run when there's an android app being build, it's a good place to hook our logic into. It also gives us direct access to the variant, so we don't have to search for it and build a releases map anymore. The tasks are configured per-variant, omitting the debug variant.
  • Register our tasks lazily to avoid early resolution via register instead of create

I tested it locally both debug and release builds and the react-native-legal json file is correctly generated in both cases. Also, our tasks run correctly for the release build, you can see here I uploaded sourcemaps: https://sentry-sdks.sentry.io/settings/projects/sentry-react-native/source-maps/23317267-0d24-5f07-9852-28630b8cf98a/

The only thing that probably needs more testing is modules collection, because it generated an empty json locally for me, but perhaps I was doing something unexpected, because I was running gradle builds directly as opposed calling yarn/npx. If someone could verify it works, that'd be great.

💡 Motivation and Context

Closes #5236

💚 How did you test it?

manually

📝 Checklist

  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing
  • No breaking changes

🔮 Next steps

Copy link
Contributor

github-actions bot commented Oct 9, 2025

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 468.80 ms 471.15 ms 2.35 ms
Size 17.75 MiB 19.70 MiB 1.95 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
77061ed+dirty 369.55 ms 408.35 ms 38.80 ms
a2bb688+dirty 409.65 ms 410.45 ms 0.80 ms
000da7a 454.46 ms 445.00 ms -9.46 ms
a0b15d6 423.06 ms 437.77 ms 14.71 ms
af9331b 449.77 ms 479.20 ms 29.43 ms
69602ce 417.47 ms 443.52 ms 26.05 ms
7480abe+dirty 411.60 ms 405.81 ms -5.78 ms
8a4ce6f 422.88 ms 408.33 ms -14.55 ms
bc9680d 375.15 ms 401.12 ms 25.97 ms
46da307 455.92 ms 443.79 ms -12.13 ms

App size

Revision Plain With Sentry Diff
77061ed+dirty 17.75 MiB 19.68 MiB 1.94 MiB
a2bb688+dirty 17.75 MiB 19.70 MiB 1.95 MiB
000da7a 17.75 MiB 19.68 MiB 1.94 MiB
a0b15d6 17.75 MiB 20.15 MiB 2.41 MiB
af9331b 17.75 MiB 19.68 MiB 1.94 MiB
69602ce 17.75 MiB 19.68 MiB 1.94 MiB
7480abe+dirty 17.75 MiB 19.68 MiB 1.94 MiB
8a4ce6f 17.75 MiB 19.68 MiB 1.94 MiB
bc9680d 17.75 MiB 20.15 MiB 2.41 MiB
46da307 17.75 MiB 19.68 MiB 1.93 MiB

Copy link
Contributor

github-actions bot commented Oct 9, 2025

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 340.96 ms 395.59 ms 54.63 ms
Size 7.15 MiB 8.43 MiB 1.28 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
d751a5d+dirty 341.61 ms 403.06 ms 61.45 ms
69602ce+dirty 375.37 ms 405.28 ms 29.91 ms
77061ed+dirty 359.40 ms 424.10 ms 64.70 ms
98f632c+dirty 323.98 ms 375.39 ms 51.41 ms
eb07ba3+dirty 419.49 ms 482.12 ms 62.63 ms
7be1f99+dirty 369.02 ms 399.60 ms 30.58 ms
a0b15d6+dirty 414.33 ms 448.85 ms 34.52 ms
5c16cdc+dirty 375.45 ms 426.62 ms 51.17 ms
7480abe+dirty 363.80 ms 431.34 ms 67.54 ms
f70acbf+dirty 520.12 ms 558.91 ms 38.79 ms

App size

Revision Plain With Sentry Diff
d751a5d+dirty 7.15 MiB 8.41 MiB 1.26 MiB
69602ce+dirty 7.15 MiB 8.41 MiB 1.26 MiB
77061ed+dirty 7.15 MiB 8.41 MiB 1.26 MiB
98f632c+dirty 7.15 MiB 8.42 MiB 1.27 MiB
eb07ba3+dirty 7.15 MiB 8.42 MiB 1.27 MiB
7be1f99+dirty 7.15 MiB 8.42 MiB 1.27 MiB
a0b15d6+dirty 7.15 MiB 8.42 MiB 1.27 MiB
5c16cdc+dirty 7.15 MiB 8.41 MiB 1.26 MiB
7480abe+dirty 7.15 MiB 8.41 MiB 1.26 MiB
f70acbf+dirty 7.15 MiB 8.41 MiB 1.26 MiB

Copy link
Contributor

github-actions bot commented Oct 9, 2025

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1224.07 ms 1237.88 ms 13.81 ms
Size 3.19 MiB 4.56 MiB 1.37 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
1bea095+dirty 1218.93 ms 1212.37 ms -6.57 ms
20daa0a+dirty 1227.71 ms 1233.72 ms 6.01 ms
ba75c7c+dirty 1236.14 ms 1240.69 ms 4.55 ms
6479fd5+dirty 1207.80 ms 1215.12 ms 7.32 ms
7480abe+dirty 1219.84 ms 1223.60 ms 3.76 ms
c4e097a+dirty 1231.35 ms 1246.91 ms 15.56 ms
69602ce+dirty 1230.59 ms 1230.84 ms 0.24 ms
d916aa3+dirty 1211.02 ms 1221.33 ms 10.31 ms
d751a5d+dirty 1212.22 ms 1217.94 ms 5.71 ms
955f2eb+dirty 1225.78 ms 1239.27 ms 13.49 ms

App size

Revision Plain With Sentry Diff
1bea095+dirty 3.19 MiB 4.55 MiB 1.37 MiB
20daa0a+dirty 3.19 MiB 4.38 MiB 1.19 MiB
ba75c7c+dirty 3.19 MiB 4.38 MiB 1.19 MiB
6479fd5+dirty 3.19 MiB 4.53 MiB 1.35 MiB
7480abe+dirty 3.19 MiB 4.53 MiB 1.35 MiB
c4e097a+dirty 3.19 MiB 4.44 MiB 1.25 MiB
69602ce+dirty 3.19 MiB 4.48 MiB 1.29 MiB
d916aa3+dirty 3.19 MiB 4.38 MiB 1.19 MiB
d751a5d+dirty 3.19 MiB 4.54 MiB 1.36 MiB
955f2eb+dirty 3.19 MiB 4.55 MiB 1.36 MiB

Copy link
Contributor

github-actions bot commented Oct 9, 2025

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1223.39 ms 1233.13 ms 9.74 ms
Size 2.63 MiB 3.99 MiB 1.36 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
1bea095+dirty 1234.14 ms 1233.96 ms -0.18 ms
20daa0a+dirty 1233.12 ms 1233.35 ms 0.22 ms
ba75c7c+dirty 1235.86 ms 1226.45 ms -9.41 ms
6479fd5+dirty 1228.48 ms 1231.32 ms 2.84 ms
7480abe+dirty 1220.53 ms 1244.18 ms 23.65 ms
c4e097a+dirty 1229.09 ms 1242.61 ms 13.53 ms
69602ce+dirty 1235.65 ms 1230.82 ms -4.83 ms
d916aa3+dirty 1221.02 ms 1228.98 ms 7.96 ms
d751a5d+dirty 1215.57 ms 1220.56 ms 4.99 ms
955f2eb+dirty 1235.06 ms 1253.88 ms 18.81 ms

App size

Revision Plain With Sentry Diff
1bea095+dirty 2.63 MiB 3.99 MiB 1.35 MiB
20daa0a+dirty 2.63 MiB 3.81 MiB 1.18 MiB
ba75c7c+dirty 2.63 MiB 3.81 MiB 1.18 MiB
6479fd5+dirty 2.63 MiB 3.96 MiB 1.33 MiB
7480abe+dirty 2.63 MiB 3.96 MiB 1.33 MiB
c4e097a+dirty 2.63 MiB 3.87 MiB 1.24 MiB
69602ce+dirty 2.63 MiB 3.91 MiB 1.28 MiB
d916aa3+dirty 2.63 MiB 3.81 MiB 1.18 MiB
d751a5d+dirty 2.63 MiB 3.98 MiB 1.34 MiB
955f2eb+dirty 2.63 MiB 3.98 MiB 1.35 MiB

Copy link
Contributor

@alwx alwx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have just checked it — it works and solves the issue. Thanks a lot!

plugins.withId('com.android.application') {
def ac = extensions.getByName("androidComponents")

ac.onVariants(androidComponents.selector().all()) { v ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: v is the release?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v is variant, but since we have one down there already, I just named it v

@lucas-zimerman
Copy link
Collaborator

Thank you for the PR! is it ready for review?

@romtsn
Copy link
Member Author

romtsn commented Oct 9, 2025

@lucas-zimerman not yet, I will mark it as ready soonish, still sorting out some stuff

@romtsn romtsn force-pushed the rz/fix/react-native-legal-compat branch from 14b894b to 6decb5a Compare October 10, 2025 11:30
@romtsn romtsn marked this pull request as ready for review October 10, 2025 11:32
@romtsn romtsn requested a review from antonis as a code owner October 10, 2025 11:32
@romtsn
Copy link
Member Author

romtsn commented Oct 10, 2025

@lucas-zimerman this is ready for review now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conflict with react-native-legal on Android

3 participants